package com.cy.pj.sys.controller;

import com.cy.pj.common.vo.JsonResult;
import com.cy.pj.sys.pojo.SysRole;
import com.cy.pj.sys.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.relational.core.sql.In;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.*;

/**
 * @Author YuBaoFu
 * @create 2025/06/03
 * @description
 */
@RestController
@RequestMapping("/role")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @RequestMapping("/doFindPageObjects")
    public JsonResult doFindPageObjects(String name, Integer pageCurrent){
        return new JsonResult(sysRoleService.findPageObjects(name,pageCurrent));
    }

    @RequestMapping("/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        sysRoleService.deleteObject(id);
        return new JsonResult("delete OK!~");
    }

    @RequestMapping("/doSaveObject")
    public JsonResult doSaveObject(SysRole sysRole,Integer[] menuIds){
        sysRoleService.saveObject(sysRole,menuIds);
        return new JsonResult("Save OK!~");
    }

    @RequestMapping("/doFindObjectById")
    public JsonResult doFindObjectById(Integer id){
        return new JsonResult(sysRoleService.findObjectById(id));
    }

    @RequestMapping("/doUpdateObject")
    public JsonResult doUpdateObject(SysRole sysRole,Integer[] menuIds){
        sysRoleService.updateObject(sysRole,menuIds);
        return new JsonResult("update ok");
    }

    @RequestMapping("doFindRoles")
    public JsonResult doFindRoles(){
        return new JsonResult(sysRoleService.findObjects());
    }

}
